﻿using System;
using System.Numerics;


class SumOfFac
{
    static BigInteger Factoriel(int number)
    {
        BigInteger factoriel = 1;
        for (int i = 1; i <= number; i++)
        {
            factoriel *= i;
        }
        return factoriel;
    }

    static double PowX(int x, int n)
    {
        double production = 1;
        for (int i = 1; i <= n; i++)
        {
            production = production * x;
        }
        return production;
    }

    static void Main()
    {
        double sum = 1;
        Console.ForegroundColor=ConsoleColor.Yellow;
        Console.WriteLine("6. Write a program that, for a given \ntwo integer numbers N and X, calculates \nthe sum S = 1 + 1!/X + 2!/X2 + … + N!/XN.\n");
        Console.ForegroundColor = ConsoleColor.White;
        Console.Write("Enter N :");
        int n = int.Parse(Console.ReadLine());
        Console.Write("Enter X :");
        int x = int.Parse(Console.ReadLine());
        for (int i = 1; i <= n; i++)
        {

            sum += (double)Factoriel(i) / (PowX(x, i));
        }
        Console.WriteLine("Result is : {0}", sum);
    }
}

